package com.ming.controller;


import com.ming.pojo.Owner;
import com.ming.service.impl.OwnerServiceImpl;
import org.springframework.aop.scope.ScopedProxyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/owner")
public class OwnerController {

    @Autowired
    OwnerServiceImpl ownerService;

    /**
     * 所有业主信息
     * @return
     */
    @RequestMapping("/allOwnerList")
    public List<Owner> allOwner() {
        return ownerService.allOwnerList();
    }

    /**
     * 通过姓名寻找业主信息
     * @param name
     * @return
     */
    @RequestMapping("/ownerByName")
    public List<Owner> ownerByName(String name) {
        return  ownerService.ownerListByName(name);
    }

    /**
     * 通过主键id查询业主id
     * @param ownerId
     * @return
     */
    @RequestMapping("/ownerById")
    public Owner ownerById(String ownerId){
        return ownerService.ownerById(ownerId);
    }

    /**
     * 添加业主信息
     * @param owner
     */
    @PostMapping("/addOwner")
    public void addOwner(@RequestBody Owner owner) {
        System.out.println(owner);
        ownerService.addOwner(owner);
    }

    /**
     * 修改业主信息
     * @param owner
     */
    @PostMapping("/updateOwner")
    public void updateOwner(@RequestBody Owner owner) {
        ownerService.updateOwner(owner);
    }

    @RequestMapping("/deleteOwner")
    public void deleteOwner(String ownerId){
        ownerService.deleteOwner(ownerId);
    }


}
